'''
Created on 16.12.2011

Group selected Objects and constrain them to selection [0]

@author: cwestphal
'''

import maya.cmds as cmds

jnt = cmds.ls (selection = True) [0]
obj = cmds.ls (selection = True)[1:]

print obj

grp = cmds.group(empty = True, name = str(obj[1]) + '_grp')
cmds.parent(grp, jnt)

cmds.makeIdentity(grp, translate = True, rotate = True, scale = True)

cmds.parent( '%s|%s'%(jnt[0], grp), world=True )

cmds.parent(obj,grp)

cmds.parentConstraint(jnt, grp)